# Problem 3
# The prime factors of 13195 are 5, 7, 13 and 29.
# What is the largest prime factor of the number 600851475143 ?

import unittest


def findLargestPrimeFactor(N):
    factor = 2
    while True:
        while N % factor == 0:
            N /= factor
        if factor > N:
            break
        factor += 1
    return  factor  

  
class TestP003(unittest.TestCase):
    def test_findLargestPrimeFactor(self):
        self.assertEqual(findLargestPrimeFactor(2), 2)
        self.assertEqual(findLargestPrimeFactor(13195), 29)
        self.assertEqual(findLargestPrimeFactor(600851475143), 6857)


if __name__ == '__main__':  
    P003 = unittest.TestLoader().loadTestsFromTestCase(TestP003)
    unittest.TextTestRunner(verbosity=2).run(P003)
    #print "The max facotor of 600851475143 is [%d]" % findLargestPrimeFactor(600851475143)  
 




    